<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
</body>
<script>
    // 1、交换两个变量
    var x = 10
    var y = 20
    // var temp
    // temp = x
    // x = y
    // y = temp
    var [y, x] = [x, y]
    console.log(x, y);
    // 2、让函数有多个返回值
    function fn(x, y) {
        return [x, y]
        // return y
    }
    console.log();
    var [x, y] = fn(10, 20)
    console.log(x, y);
    // 3、解决形参为undefined的问题
    function fn_1({ age = 20 }) {
        console.log(age);
    }
    fn_1({ age: 30 })
</script>

</html>